<?php
/**
 * 検索結果一覧画面・検索表示欄レイアウト表示<br />
 *
 * @package    apamanshop
 * @author     SS木下
 * @copyright  コピーライト(要確認)
 */
class Rstobi_Model_SearchDisplay extends Rstobi_Model_Base
{
	/**
	* 地域・沿線欄表示
	*/
	public function getSearchConditionChiikiEnsen ($params, &$data)
	{
		$model_common = new Search_Model_Common();

		//検索区分コードの取得
		$SrhKbn = $params['SrhKbn'];

		//検索タイプコードの取得
		$SrhType = $params['SrhType'];

		$SearchTypeFlag = $this->getSearchTypeFlag($SrhKbn,$SrhType);

		//住所検索
		if($SearchTypeFlag == Apm_Config_Search::SRHTYPE_JYUSYO){
			if($SrhKbn == Apm_Config_Search::SRHKBN_BUKENREQUEST_SYATAKU){
				$data['condition1'] .= '<span class="spot">都道府県(市区町村・町名)：</span>';
			} else{
				$data['condition1'] .= '<span class="spot">都道府県(市区町村)：</span>';
			}
			$CityTownName = $model_common->getFormSearchName($params, 1, '');

			if (isset($CityTownName['search_name'])){
				foreach ($CityTownName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}

		//沿線検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_ENSENEKI){
			$data['condition1'] .= '<span class="spot">沿線・駅：</span>';
			$EnsenName = $model_common->getFormSearchName($params, 1, '');

			if (isset($EnsenName['search_name'])){
				foreach ($EnsenName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}
		//路線図検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_ROSENZU){
			$data['condition1'] .= '<span class="spot">都道府県・駅：</span>';
			$EnsenName = $model_common->getFormSearchName($params, 1, '');

			if (isset($EnsenName['search_name'])){
				foreach ($EnsenName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}
		//通勤・通学時間検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_TUKINTUGAKU){
			$data['condition1'] .= '<span class="spot">物件の最寄り駅：</span>';
			$data['condition1'] .= $params['TgtStNm'];
			$data['condition1'] .= ' <span class="spot">所要時間：</span>';
			$data['condition1'] .= $params['EndRangeTimeFrom']."分から".$params['EndRangeTimeTo']."分まで";
			$data['condition1'] .= ' <span class="spot">乗換回数：</span>';
			if($params['TransferCount'] == "0"){
				$data['condition1'] . "乗換なし";
			}else{
				$data['condition1'] . $params['TrasferCount']."回";
			}
		//フリーワード検索
		}else{
			$data['condition1'] .= '<span class="spot">キーワード：</span>';
			$data['condition1'] .= $params["freeword"];
		}
	}
	/**
	* 地域・沿線欄表示
	*/
	public function getSearchConditionChiikiEnsen2 ($params, &$data)
	{
		$model_common = new Search_Model_Common();

		//検索区分コードの取得
		$SrhKbn = $params['SrhKbn'];

		//検索タイプコードの取得
		$SrhType = $params['SrhType'];

		$SearchTypeFlag = $this->getSearchTypeFlag($SrhKbn,$SrhType);

		//住所検索
		if($SearchTypeFlag == Apm_Config_Search::SRHTYPE_JYUSYO){
			if($SrhKbn == Apm_Config_Search::SRHKBN_BUKENREQUEST_SYATAKU){
				$data['condition1'] .= '<strong>都道府県(市区町村・町名)：</strong>';
			} else{
				$data['condition1'] .= '<strong>都道府県(市区町村)：</strong>';
			}
			$CityTownName = $model_common->getFormSearchName($params, 1, '');

			if (isset($CityTownName['search_name'])){
				foreach ($CityTownName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}

		//沿線検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_ENSENEKI){
			$data['condition1'] .= '<strong>沿線・駅：</strong>';
			$EnsenName = $model_common->getFormSearchName($params, 1, '');

			if (isset($EnsenName['search_name'])){
				foreach ($EnsenName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}
		//路線図検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_ROSENZU){
			$data['condition1'] .= '<strong>都道府県・駅：</strong>';
			$EnsenName = $model_common->getFormSearchName($params, 1, '');

			if (isset($EnsenName['search_name'])){
				foreach ($EnsenName['search_name'] as $Name){
					$data['condition1'] .= $Name;
					$data['condition1'] .= " ";
				}
			}
		//通勤・通学時間検索
		}else if($SearchTypeFlag == Apm_Config_Search::SRHKBN_TUKINTUGAKU){
			$data['condition1'] .= '<strong>物件の最寄り駅：</strong>';
			$data['condition1'] .= $params['TgtStNm'];
			$data['condition1'] .= ' <strong>所要時間：</strong>';
			$data['condition1'] .= $params['EndRangeTimeFrom']."分から".$params['EndRangeTimeTo']."分まで";
			$data['condition1'] .= ' <strong>乗換回数：</strong>';
			if($params['TransferCount'] == "0"){
				$data['condition1'] . "乗換なし";
			}else{
				$data['condition1'] . $params['TrasferCount']."回";
			}
		//フリーワード検索
		}else{
			$data['condition1'] .= '<strong>キーワード：</strong>';
			$data['condition1'] .= $params["freeword"];
		}
	}
	/**
	* 基本条件欄表示
	*/
	public function getSearchConditionKihon ($params, &$data)
	{

		//初期値	* 2011/06/22 SEO対策:Ajax削除	初回表示時のパラメータ不足を補う為
		$param_init=array( 	'tinryo1'	=> 0	,	'tinryo2'	=> 9999999	,	'meyasu_tinryo'	=> 'normal'	,
							'senyu1'	=> 1	,	'senyu2' 	=> 99999	,	'ekitoho' 		=> 0		,
							'built'		=> 0	,	'jyohou'	=> 0 		,	'syokihiyo'		=> 0
						 ); 
		//初期値セット
		foreach( $param_init as $key => $init_val ) {
			//パラメータがセットされていない
		    if( !isset( $params[$key] ) ) {
				$params[$key] = $init_val;
			}else{
			}
		}

		//初期費用
		$data['condition2'] .= '<span class="spot">初期費用：</span>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_SYOKIHIYO[$params['syokihiyo']];
		//if (Apm_Config_Search::$KENSAKU_SYOKIHIYO[$params['syokihiyo']] = "w0"){
		//	$params['shikireizero'] = "on";
		//}
		//賃料/目安賃料
		$chinryo_type =  Apm_Config_Search::$KENSAKU_CHINRYO_MEYASU[$params['meyasu_tinryo']];
		//賃料（下限・上限）
		$data['condition2'] .= ' <span class="spot">'.$chinryo_type.'：</span>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_CHINRYO_MIN[$params['tinryo1']]."～".Apm_Config_Search::$KENSAKU_CHINRYO_MAX[$params['tinryo2']];
		//賃料(管理費・共益費込み/敷金礼金なし)
		$data['condition2'] .= $this->getChekboxValue(Apm_Config_Search::$KENSAKU_CHINRYO_CHECK,$params,0,'');


		//割引サービス
		$data['condition2'] .= $this->getChekboxValue(Apm_Config_Search::$KENSAKU_WARIBIKI_SERVICE,$params,1,'割引サービス');

		//間取り
		$data['condition2'] .= $this->getChekboxValue(Apm_Config_Search::$KENSAKU_MADORI,$params,2,'間取り');

		//専有面積（下限・上限）
		$data['condition2'] .= ' <span class="spot">専有面積：</span>';
		if($params['senyu1'] <> '1'){
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MIN[$params['senyu1']]."m<sup>2</sup>";
		}else{
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MIN[$params['senyu1']];
		}

		$data['condition2'] .= "～";
		if($params['senyu2'] <> '99999'){
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MAX[$params['senyu2']]."m<sup>2</sup>";
		}else{
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MAX[$params['senyu2']];
		}
		//建物種別
		$data['condition2'] .= $this->getChekboxValue(Apm_Config_Search::$KENSAKU_TATEMONO_SYUBETU,$params,2,'建物種別');

		//最寄り駅からの時間（徒歩）
		$data['condition2'] .= ' <span class="spot">最寄り駅からの時間（徒歩）：</span>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_TATEMONO_TOHO[$params['ekitoho']];
		if($params['bas_riyou']){
			$data['condition2'] .= ' バス利用可';
		}

		//築年数
		$data['condition2'] .= ' <span class="spot">築年数：</span>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_CHIKUNENSU[$params['built']];

		//情報の新しさ
		$data['condition2'] .= ' <span class="spot">情報の新しさ：</span>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_JYOHOU[$params['jyohou']];

		//画像
		$data['condition2'] .= $this->getChekboxValue(Apm_Config_Search::$KENSAKU_GAZOU,$params,1,'画像');

		//キャンペーン特集
		$data['condition2'] .= ' <span class="spot">キャンペーン特集：</span>';
		$hash = $this->getCampaignData($params);

		//ハッシュの生成
		$kensaku_campaign_hash = array();
		foreach($hash as $key => $value){
			$kensaku_campaign_hash[$value['M94_CAMPAIGN_CD']] = $value['M94_CAMPAIGN_RYAKUSHOU'];
		}
		$data['condition2'] .= $this->getChekboxValueCampaign($kensaku_campaign_hash,$params);
	}
	/**
	* 基本条件欄表示
	*/
	public function getSearchConditionKihon2 ($params, &$data)
	{

		//初期値	* 2011/06/22 SEO対策:Ajax削除	初回表示時のパラメータ不足を補う為
		$param_init=array( 	'tinryo1'	=> 0	,	'tinryo2'	=> 9999999	,	'meyasu_tinryo'	=> 'normal'	,
							'senyu1'	=> 1	,	'senyu2' 	=> 99999	,	'ekitoho' 		=> 0		,
							'built'		=> 0	,	'jyohou'	=> 0 		,	'syokihiyo'		=> 0
						 ); 
		//初期値セット
		foreach( $param_init as $key => $init_val ) {
			//パラメータがセットされていない
		    if( !isset( $params[$key] ) ) {
				$params[$key] = $init_val;
			}else{
			}
		}

		//初期費用
		$data['condition2'] .= '<strong>初期費用：</strong>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_SYOKIHIYO[$params['syokihiyo']];
		//if (Apm_Config_Search::$KENSAKU_SYOKIHIYO[$params['syokihiyo']] = "w0"){
		//	$params['shikireizero'] = "on";
		//}
		//賃料/目安賃料
		$chinryo_type =  Apm_Config_Search::$KENSAKU_CHINRYO_MEYASU[$params['meyasu_tinryo']];
		//賃料（下限・上限）
		$data['condition2'] .= ' <strong>'.$chinryo_type.'：</strong>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_CHINRYO_MIN[$params['tinryo1']]."～".Apm_Config_Search::$KENSAKU_CHINRYO_MAX[$params['tinryo2']];
		//賃料(管理費・共益費込み/敷金礼金なし)
		$data['condition2'] .= $this->getChekboxValue2(Apm_Config_Search::$KENSAKU_CHINRYO_CHECK,$params,0,'');


		//割引サービス
		$data['condition2'] .= $this->getChekboxValue2(Apm_Config_Search::$KENSAKU_WARIBIKI_SERVICE,$params,1,'割引サービス');

		//間取り
		$data['condition2'] .= $this->getChekboxValue2(Apm_Config_Search::$KENSAKU_MADORI,$params,2,'間取り');

		//専有面積（下限・上限）
		$data['condition2'] .= ' <strong>専有面積：</strong>';
		if($params['senyu1'] <> '1'){
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MIN[$params['senyu1']]."m<sup>2</sup>";
		}else{
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MIN[$params['senyu1']];
		}

		$data['condition2'] .= "～";
		if($params['senyu2'] <> '99999'){
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MAX[$params['senyu2']]."m<sup>2</sup>";
		}else{
			$data['condition2'] .= Apm_Config_Search::$KENSAKU_SENYU_MENSEKI_MAX[$params['senyu2']];
		}
		//建物種別
		$data['condition2'] .= $this->getChekboxValue2(Apm_Config_Search::$KENSAKU_TATEMONO_SYUBETU,$params,2,'建物種別');

		//最寄り駅からの時間（徒歩）
		$data['condition2'] .= ' <strong>最寄り駅からの時間（徒歩）：</strong>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_TATEMONO_TOHO[$params['ekitoho']];
		if($params['bas_riyou']){
			$data['condition2'] .= ' バス利用可';
		}

		//築年数
		$data['condition2'] .= ' <strong>築年数：</strong>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_CHIKUNENSU[$params['built']];

		//情報の新しさ
		$data['condition2'] .= ' <strong>情報の新しさ：</strong>';
		$data['condition2'] .= Apm_Config_Search::$KENSAKU_JYOHOU[$params['jyohou']];

		//画像
		$data['condition2'] .= $this->getChekboxValue2(Apm_Config_Search::$KENSAKU_GAZOU,$params,1,'画像');

		//キャンペーン特集
		$data['condition2'] .= ' <strong>キャンペーン特集：</strong>';
		$hash = $this->getCampaignData($params);

		//ハッシュの生成
		$kensaku_campaign_hash = array();
		foreach($hash as $key => $value){
			$kensaku_campaign_hash[$value['M94_CAMPAIGN_CD']] = $value['M94_CAMPAIGN_RYAKUSHOU'];
		}
		$data['condition2'] .= $this->getChekboxValueCampaign($kensaku_campaign_hash,$params);
	}

	/**
	* こだわり条件欄表示
	*/
	public function getSearchConditionKodawari ($params, &$data)
	{

		$all_count = 0;
		$hash = $this->getKodawariData($params);

/*
		//ハッシュの生成
		$result = array();
		foreach($hash as $key => $value){
			$result[$value['W74_KODAWARI_ID']]
				= array(
					'KODAWARI_TYPE' => $value['W74_KODAWARI_TYPE'],
					'KODAWARI_NANE' => $value['W74_KODAWARI_NAME']
			);
		}
		$KodawariHash = array();
		//キーワード変換（KODAWARI_TYPEごと:1から10）
		for($i=1;$i<=11;$i++){
			foreach($result as $key => $value){
				if($i == $value['KODAWARI_TYPE']){
					$KodawariHash["kodawari".$key] = $value['KODAWARI_NANE'];
				}
			}
		}
*/
		$KodawariHash = array();
		foreach($hash as $key => $value){
			$KodawariHash["kodawari".$value['W74_KODAWARI_ID']] = $value['W74_KODAWARI_NAME'];
		}

		//キーワード変換
		$data['condition3'] .= $this->getChekboxValueKodawari($KodawariHash,$params,$all_count);
		if($all_count == 0){
			$data['condition3'] .='指定なし';
		}
	}

	/**
	* チェックボックスの有無によりテキストに追加
	*/
	private function getChekboxValue ($hash,$params,$flag,$subject)
	{
		$text = '';
		$textin = '';
		$counter = 0;
		$i = 0;
		if($flag <> 0){
			$text .= '<span class="spot">'.$subject.'：</span>';
		}
		foreach($hash as $key => $value){
			if($params[$key] <> ""){
				if($counter <> 0){
					$textin .= ',';
				}
				$textin .= $value;
				$counter++;
			}
			$i++;
		}
		if($counter == 0 && $flag == 1){
			$text .= '指定なし';
		}else if(($counter == 0 || $counter == $i) && $flag == 2){
			$text .= '全て';
		}else{
			$text .= $textin;
		}

		return $text;
	}
	/**
	* チェックボックスの有無によりテキストに追加
	*/
	private function getChekboxValue2 ($hash,$params,$flag,$subject)
	{
		$text = '';
		$textin = '';
		$counter = 0;
		$i = 0;
		if($flag <> 0){
			$text .= '<strong>'.$subject.'：</strong>';
		}
		foreach($hash as $key => $value){
			if($params[$key] <> ""){
				if($counter <> 0){
					$textin .= ',';
				}
				$textin .= $value;
				$counter++;
			}
			$i++;
		}
		if($counter == 0 && $flag == 1){
			$text .= '指定なし';
		}else if(($counter == 0 || $counter == $i) && $flag == 2){
			$text .= '全て';
		}else{
			$text .= $textin;
		}

		return $text;
	}

	/**
	* チェックボックスの有無によりテキストに追加（キャンペーン）
	*/
	private function getChekboxValueCampaign ($hash,$params)
	{
		$text = '';
		$textin = '';
		$counter = 0;
		if(isset($params['campaign'])){

			foreach($params['campaign'] as $campaign_code){
				if($counter <> 0){
					$textin .= ',';
				}
				$textin .= $hash[$campaign_code];
				$counter++;
			}
		}
		if($counter <> 0){
			$text .= $textin;
		}else{
			$text .= '指定なし';
		}

		return $text;
	}

	/**
	* チェックボックスの有無によりテキストに追加（こだわり条件）
	*/
	private function getChekboxValueKodawari ($hash,$params,&$all_count)
	{
		$text = '';
		$textin = '';
		$counter = 0;
			foreach($hash as $key => $value){
			if($params[$key] <> ""){
				if($counter <> 0){
					$textin .= ',';
				}
				$textin .= $value;
				$counter++;
			}
		}
		if($counter <> 0){
			$text .= $textin;
		}
		$all_count += $counter;

		return $text;
	}

	/**
	* 住所・沿線・フリーワードのいずれかを判別
	*/
	private function getSearchTypeFlag ($SrhKbn,$SrhType)
	{
		// 住所検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_JYUSYO ){
			return Apm_Config_Search::SRHTYPE_JYUSYO;
		}

		//沿線・駅検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_ENSENEKI ){
			return Apm_Config_Search::SRHTYPE_ENSENEKI;
		}

		//路線図検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_ROSENZU ){
			return Apm_Config_Search::SRHKBN_ROSENZU;
		}

		//通勤・通学時間検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_TUKINTUGAKU ){
			return Apm_Config_Search::SRHKBN_TUKINTUGAKU;
		}

		//住みたい駅名検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_SUMITAIEKI ){
			return Apm_Config_Search::SRHTYPE_ENSENEKI;
		}

		//キーワード検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_FREEWORD ){
			return Apm_Config_Search::SRHKBN_FREEWORD;
		}

		//家賃相場検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_YACHINSOUBA){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//賃料×間取り検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_CHINRYOMADORI){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//住居形態検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_JYUKYOKEITAI){
			return Apm_Config_Search::SRHTYPE_JYUSYO;
		}

		//こだわり物件検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_KODAWARI){
			return Apm_Config_Search::SRHTYPE_JYUSYO;
		}

		//特集物件検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_TOKUSYU){
			return Apm_Config_Search::SRHTYPE_JYUSYO;
		}

		//キャンペーン物件検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_CAMPAIGN){
			return Apm_Config_Search::SRHTYPE_JYUSYO;
		}

			//マイページ検索条件登録検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_MYPAGE_ADD){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//マイページ検索条件変更検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_MYPAGE_UPD){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//物件リクエスト検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_BUKENREQUEST){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//社宅検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_SYATAKU){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}

		//社宅物件リクエスト検索
		if($SrhKbn == Apm_Config_Search::SRHKBN_BUKENREQUEST_SYATAKU){
			if($SrhType == Apm_Config_Search::SRHTYPE_JYUSYO){
				return Apm_Config_Search::SRHTYPE_JYUSYO;
			}else{
				return Apm_Config_Search::SRHTYPE_ENSENEKI;
			}
		}
	}

	/**
	* キャンペン物件データ取得
	*/
	private function getCampaignData($params)
    {
        $db_params = array();
        $sql = $this->generateCampaignSql($params, $db_params);
		return  $this->dbGetList($sql, $db_params);
    }

	/**
	* こだわり物件SQL文の取得
 	*/
    private function generateCampaignSql($params,&$db_params)
    {

    	$db_params["nowDate"] = date("Ymd");

		$sql = "";
		$sql .= "SELECT ";
 		$sql .= "    M94_CAMPAIGN_CD, ";
		$sql .= "    M94_CAMPAIGN_RYAKUSHOU ";
		$sql .= "FROM ";
		$sql .= "    M94CAMPAIGN ";
		$sql .= "WHERE ";
				//有効期間(開始がnullの場合は無効とする。終了がnullの場合はエンドレスとする)
		$sql .= "    :nowDate BETWEEN NVL(M94_START_YMD, '99999999') AND NVL(M94_END_YMD, '99999999') AND";
 		$sql .= "    M94_CAMPAIGN_HYOUZI = 1 AND ";
		$sql .= "    M94_DELETE_FLAG = 0 ";
		$sql .= "ORDER BY ";
		$sql .= "    M94_CAMPAIGN_CD ";

		return $sql;
    }

	/**
	* こだわり物件データ取得
	*/
	private function getKodawariData($params)
    {
        $db_params = array();
        $sql = $this->generateKodawariSql($params, $db_params);
		return  $this->dbGetList($sql, $db_params);
    }

	/**
	* こだわり物件SQL文の取得
 	*/
    private function generateKodawariSql($params,$db_params)
    {
		$sql = "";
		$sql .= "SELECT ";
		$sql .= "    W74_KODAWARI_ID,";
		$sql .= "    W74_KODAWARI_NAME, ";
		$sql .= "    W74_KODAWARI_TYPE ";
		$sql .= "FROM ";
		$sql .= "    W74KODAWARI ";
		$sql .= "  , M45KODAWARI_TYPE ";
		$sql .= "WHERE  ";
		$sql .= "    W74_KODAWARI_TYPE <> 0 ";
		$sql .= "AND W74_KODAWARI_TYPE = M45_KODAWARI_TYPE ";
		$sql .= "ORDER BY ";
		$sql .= "    M45_PRIORITY_NO,";
		$sql .= "    W74_PRIORITY_NO ";

	   return $sql;
    }


}
?>